library respon;

import 'package:json_annotation/json_annotation.dart';

part 'respon.g.dart';

//生成命令     flutter packages pub run build_runner build
//自动生成命令  flutter packages pub run build_runner watch

@JsonSerializable()
class Tag extends Object with _$TagSerializerMixin {
  String name;
  String url;

  Tag(this.name, this.url);

  factory Tag.fromJson(Map<String, dynamic> json) => _$TagFromJson(json);
}

@JsonSerializable()
class OneInfo extends Object with _$OneInfoSerializerMixin {
  String apkLink;
  String author;
  int chapterId;
  String chapterName;
  bool collect;
  int courseId;
  String desc;
  String envelopePic;
  bool fresh;
  int id;
  String link;
  String niceDate;
  String origin;
  String projectLink;
  int publishTime;
  int superChapterId;
  String superChapterName;
  List<Tag> tags;
  String title;
  int type;
  int userId;
  int visible;
  int zan;

  OneInfo(
      this.apkLink,
      this.author,
      this.chapterId,
      this.chapterName,
      this.collect,
      this.courseId,
      this.desc,
      this.envelopePic,
      this.fresh,
      this.id,
      this.link,
      this.niceDate,
      this.origin,
      this.projectLink,
      this.publishTime,
      this.superChapterId,
      this.superChapterName,
      this.tags,
      this.title,
      this.type,
      this.userId,
      this.visible,
      this.zan);

  factory OneInfo.fromJson(Map<String, dynamic> json) =>
      _$OneInfoFromJson(json);
}

@JsonSerializable()
class OnePageData extends Object with _$OnePageDataSerializerMixin {
  int curPage;
  List<OneInfo> datas;
  int offset;
  bool over;
  int pageCount;
  int size;
  int total;

  OnePageData(this.curPage, this.datas, this.offset, this.over, this.pageCount,
      this.size, this.total);

  factory OnePageData.fromJson(Map<String, dynamic> json) =>
      _$OnePageDataFromJson(json);
}

@JsonSerializable()
class Response extends Object with _$ResponseSerializerMixin {
  OnePageData data;
  num errorCode;
  String errorMsg;

  Response(this.data, this.errorCode, this.errorMsg);

  factory Response.fromJson(Map<String, dynamic> json) =>
      _$ResponseFromJson(json);
}
